﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;  //It provides a built-in set of validation attributes that you can apply declaratively to any class or property

namespace CapacitacionMVC.Models
{
    
    public class Movie
    {
        //properties
        public int Id { get; set; }

       

        [Required(ErrorMessage = "se debe agregar un título")]  //the message show when there is an error of validating this field
        public string Title { get; set; }

        [DataType(DataType.Date)]
        [Required(ErrorMessage = "Se necesita una fecha de estreno")]
        public DateTime ReleaseDate { get; set; }
        
        [Required(ErrorMessage = "Se debe especificar un género")]
        public string Genre { get; set; }
        
        [Required(ErrorMessage = "Se necesita agregar un precio")]
        [Range(1, 100, ErrorMessage = "El precio debe estar entre $1 y $100")]
        [DataType(DataType.Currency)]
        public decimal Price { get; set; }

        [StringLength(5)]
        public string Rating { get; set; } 

    }

    
    public class MovieDBContext : DbContext
    {
        public DbSet<Movie> Movies { get; set; }
    }
}